﻿package kliment.utils {
	import kliment.utils._String;
	
	/**
	* ...
	* @author Kliment
	*/
	public class TimeOutput {
		public static const HH:String = "hh";
		public static const MM:String = "mm";
		public static const SS:String = "ss";
		public static const HA:String = "ha";
		public static const MA:String = "ma";
		public static const SA:String = "sa";
		public static const HR:String = "hr";
		public static const MR:String = "mr";
		public static const SR:String = "sr";
		private const PATTERN_FLAGS:String = "gi";
		
		private var _format:String;
		private var _allMilliseconds:Number;
		
		public function TimeOutput(format:String):void {
			_format = format;
		}
		
		public function convert(milliseconds:Number, allMilliseconds:Number):String {
			_allMilliseconds = allMilliseconds;
			
			var str:String = _format;
			/*str = str.replace(new RegExp(HH, PATTERN_FLAGS), getHours(seconds));
			str = str.replace(new RegExp(MM, PATTERN_FLAGS), getMinutes(seconds));
			str = str.replace(new RegExp(SS, PATTERN_FLAGS), getSeconds(seconds));
			str = str.replace(new RegExp(HA, PATTERN_FLAGS), getHours(allSeconds));
			str = str.replace(new RegExp(MA, PATTERN_FLAGS), getMinutes(allSeconds));
			str = str.replace(new RegExp(SA, PATTERN_FLAGS), getSeconds(allSeconds));
			str = str.replace(new RegExp(HR, PATTERN_FLAGS), getHours(seconds, true));
			str = str.replace(new RegExp(MR, PATTERN_FLAGS), getMinutes(seconds, true));
			str = str.replace(new RegExp(SR, PATTERN_FLAGS), getSeconds(seconds, true));*/
			return str;
		}
		
		public function get format():String { return _format; }
		public function set format(value:String):void {
			if (_format != value)
				_format = value;
		}
	}
	
}